Grid Layout Control
These view modifiers are used to control the layout behavior of individual views placed inside a Grid structure. They provide fine-grained control over cell spanning, alignment, and sizing, consistent with SwiftUI’s grid system.
gridCellColumns
Tells a view in a grid to span across multiple columns.
Type
Description
Use this modifier to expand a single view across two or more columns. This is typically used for headers or wide content rows.
Example
gridCellAnchor
Specifies a custom alignment anchor within the grid cell.
Type
Description
Use this modifier to align the content of a cell to a specific anchor point, either using a named keyword (such as "center" or "topLeading") or a custom { x, y } point.
Example
gridCellUnsizedAxes
Prevents the view from expanding in the specified directions when placed in a grid cell.
Type
Description
This modifier tells the grid not to assign extra size to the view along specified axes, allowing the view to tightly wrap its content.
Options
"horizontal"– Prevent horizontal expansion"vertical"– Prevent vertical expansion"all"– Prevent expansion in both directions
Example
gridColumnAlignment
Overrides the default horizontal alignment of the column the view appears in.
Type
Description
Affects how all cells in the column are aligned horizontally. Only one view in a column needs to specify this to affect the whole column.
Example
Grid and GridRow Structure
These modifiers are only applicable within the context of the Grid and GridRow components.
Grid
A container that lays out content in a two-dimensional grid.
Props
alignment?: Alignment– Alignment of child views in grid cellshorizontalSpacing?: number– Spacing between columnsverticalSpacing?: number– Spacing between rows
Example
GridRow
Represents a horizontal row of views inside a Grid.
Props
alignment?: VerticalAlignment– Vertical alignment for cells in the row
